#ifndef TREE_MATCH_HPP
#define	TREE_MATCH_HPP

#include "ast.hpp"
#include "cfg.hpp"
#include <boost/optional.hpp>
using boost::optional;
class CFGvertex;
class ASTnode;
class variable;
class arith;
class bexp;
class array_element;


#define TRY_TYPE(TYPE, DEST, FROM)  TYPE DEST = dynamic_cast<TYPE>(FROM)
		

/**
 * Scalar assignment
 */
struct sa {variable *x; arith *a;};
optional<sa> x_eq_a(CFGvertex *n);

/**
 * Array assignment
 */
struct aa {array_element *A; arith *a1; arith *a2;};
optional<aa> Aa1_eq_a2(CFGvertex *n);

/**
 * Read statement
 */
struct rst {variable *x;};
optional<rst> read_x(CFGvertex *n);

/**
 * Read statement into array
 */
struct rsta {array_element *A; arith *a1;};
optional<rsta> read_Aa1(CFGvertex *n);

/**
 * Write statement
 */
struct wst {arith *a;};
optional<wst> write_a(CFGvertex *n);

/**
 * Skip statement
 */
struct ss {};
optional<ss> skip(CFGvertex *n);

/**
 * Boolean expression
 */
struct be {bexp *b;};
optional<be> b(CFGvertex *n);   

/**
 * Boolean predicate
 */
struct pr {bexp *predicate;};
optional<pr> pred(CFGvertex *n);   

#endif	/* TREE_MATCH_HPP */

